import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-08-19
 * Time: 10:08
 */
public class demo2 {
    public static void main(String[] args) {
        Object locker1 = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() -> {

            try{
                System.out.println("wait 之前");
                synchronized(locker1){
                    locker1.wait();
                }
                System.out.println("wait 之后");
            }catch(InterruptedException e){
                throw new RuntimeException();
            }
        });

        Thread t2 = new Thread(() -> {
            Scanner sc = new Scanner(System.in);
            System.out.println("输入任何内容，通知唤醒t1");
            sc.next();
            synchronized(locker1){
                locker1.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
